%module OgreTextureUnitState

%{
#include "OGRE/OgreTextureUnitState.h"
	%}

%import "OgrePrerequisites.i"
%import "OgreCommon.i"
%import "OgreBlendMode.i"
%import "OgreMath.i"
 //#include "OgreMatrix4.h"
 //#include "OgreIteratorWrappers.h"
%import "OgreString.i"
%import "OgreTexture.i"
%import "OgrePass.i"
%import "OgrePixelFormat.i"

namespace Ogre {

	class TextureUnitState //: public TextureUnitStateAlloc
    {
    public:

        enum TextureEffectType
        {
            /// Generate all texture coords based on angle between camera and vertex
            ET_ENVIRONMENT_MAP,
            /// Generate texture coords based on a frustum
            ET_PROJECTIVE_TEXTURE,
            /// Constant u/v scrolling effect
            ET_UVSCROLL,
			/// Constant u scrolling effect
            ET_USCROLL,
			/// Constant u/v scrolling effect
            ET_VSCROLL,
            /// Constant rotation
            ET_ROTATE,
            /// More complex transform
            ET_TRANSFORM

        };

        enum EnvMapType
        {
            /// Envmap based on vector from camera to vertex position, good for planar geometry
            ENV_PLANAR,
            /// Envmap based on dot of vector from camera to vertex and vertex normal, good for curves
            ENV_CURVED,
            /// Envmap intended to supply reflection vectors for cube mapping
            ENV_REFLECTION,
            /// Envmap intended to supply normal vectors for cube mapping
            ENV_NORMAL
        };

        enum TextureTransformType
        {
            TT_TRANSLATE_U,
            TT_TRANSLATE_V,
            TT_SCALE_U,
            TT_SCALE_V,
            TT_ROTATE
        };

        enum TextureAddressingMode
        {
            /// Texture wraps at values over 1.0
            TAM_WRAP,
            /// Texture mirrors (flips) at joins over 1.0
            TAM_MIRROR,
            /// Texture clamps at 1.0
            TAM_CLAMP,
            /// Texture coordinates outside the range [0.0, 1.0] are set to the border colour
            TAM_BORDER
        };

	struct UVWAddressingMode
	{
		TextureAddressingMode u, v, w;
	};

        enum TextureCubeFace
        {
            CUBE_FRONT = 0,
            CUBE_BACK = 1,
            CUBE_LEFT = 2,
            CUBE_RIGHT = 3,
            CUBE_UP = 4,
            CUBE_DOWN = 5
        };

        struct TextureEffect {
            TextureEffectType type;
            int subtype;
            Real arg1, arg2;
            WaveformType waveType;
            Real base;
            Real frequency;
            Real phase;
            Real amplitude;
//            Controller<Real>* controller;
//            const Frustum* frustum;
        };

//        typedef multimap<TextureEffectType, TextureEffect>::type EffectMap;

        TextureUnitState(Pass* parent);

        TextureUnitState(Pass* parent, const TextureUnitState& oth );

        TextureUnitState & operator = ( const TextureUnitState& oth );

        ~TextureUnitState();

		TextureUnitState( Pass* parent, const String& texName, unsigned int texCoordSet = 0);

        const String& getTextureName(void) const;

        void setTextureName( const String& name, TextureType ttype = TEX_TYPE_2D);

        void setTexture( const TexturePtr& texPtr);

        void setCubicTextureName( const String& name, bool forUVW = false );

        void setCubicTextureName( const String* const names, bool forUVW = false );

        void setCubicTexture( const TexturePtr* const texPtrs, bool forUVW = false );

        void setAnimatedTextureName( const String& name, unsigned int numFrames, Real duration = 0 );

        void setAnimatedTextureName( const String* const names, unsigned int numFrames, Real duration = 0 );

//        std::pair< size_t, size_t > getTextureDimensions( unsigned int frame = 0 ) const;

        void setCurrentFrame( unsigned int frameNumber );

        unsigned int getCurrentFrame(void) const;

        const String& getFrameTextureName(unsigned int frameNumber) const;

        void setFrameTextureName(const String& name, unsigned int frameNumber);

        void addFrameTextureName(const String& name);

        unsigned int getNumFrames(void) const;

	enum BindingType
	{
		/** Regular fragment processing unit - the default. */
		BT_FRAGMENT = 0,
		/** Vertex processing unit - indicates this unit will be used for 
			a vertex texture fetch.
		*/
		BT_VERTEX = 1
	};

	enum ContentType
	{
		/// Normal texture identified by name
		CONTENT_NAMED = 0,
		/// A shadow texture, automatically bound by engine
		CONTENT_SHADOW = 1,
		/// A compositor texture, automatically linked to active viewport's chain
		CONTENT_COMPOSITOR = 2
	};

	void setBindingType(BindingType bt);

	BindingType getBindingType(void) const;

	void setContentType(ContentType ct);

	ContentType getContentType(void) const;

        bool isCubic(void) const;

        bool is3D(void) const;

        TextureType getTextureType(void) const;

        void setDesiredFormat(PixelFormat desiredFormat);

        PixelFormat getDesiredFormat(void) const;

        void setNumMipmaps(int numMipmaps);

        int getNumMipmaps(void) const;

        void setIsAlpha(bool isAlpha);

        bool getIsAlpha(void) const;

	void setHardwareGammaEnabled(bool enabled);

	bool isHardwareGammaEnabled() const;

        unsigned int getTextureCoordSet(void) const;

        void setTextureCoordSet(unsigned int set);

//       void setTextureTransform(const Matrix4& xform);

//        const Matrix4& getTextureTransform(void) const;

        void setTextureScroll(Real u, Real v);

        void setTextureUScroll(Real value);

        Real getTextureUScroll(void) const;

        void setTextureVScroll(Real value);

        Real getTextureVScroll(void) const;

        void setTextureUScale(Real value);

        Real getTextureUScale(void) const;

        void setTextureVScale(Real value);

        Real getTextureVScale(void) const;

        void setTextureScale(Real uScale, Real vScale);

        void setTextureRotate(const Radian& angle);

        const Radian& getTextureRotate(void) const;

        const UVWAddressingMode& getTextureAddressingMode(void) const;

        void setTextureAddressingMode( TextureAddressingMode tam);

        void setTextureAddressingMode( TextureAddressingMode u, 
			TextureAddressingMode v, TextureAddressingMode w);

        void setTextureAddressingMode( const UVWAddressingMode& uvw);

        void setTextureBorderColour(const ColourValue& colour);

        const ColourValue& getTextureBorderColour(void) const;

        void setColourOperationEx(
            LayerBlendOperationEx op,
            LayerBlendSource source1 = LBS_TEXTURE,
            LayerBlendSource source2 = LBS_CURRENT,

            const ColourValue& arg1 = ColourValue::White,
            const ColourValue& arg2 = ColourValue::White,

            Real manualBlend = 0.0);

        void setColourOperation( const LayerBlendOperation op);

//        void setColourOpMultipassFallback( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);

        const LayerBlendModeEx& getColourBlendMode(void) const;

        const LayerBlendModeEx& getAlphaBlendMode(void) const;

        SceneBlendFactor getColourBlendFallbackSrc(void) const;

        SceneBlendFactor getColourBlendFallbackDest(void) const;

        void setAlphaOperation(LayerBlendOperationEx op,
            LayerBlendSource source1 = LBS_TEXTURE,
            LayerBlendSource source2 = LBS_CURRENT,
            Real arg1 = 1.0,
            Real arg2 = 1.0,
            Real manualBlend = 0.0);


        void addEffect(TextureEffect& effect);

        void setEnvironmentMap(bool enable, EnvMapType envMapType = ENV_CURVED);

        void setRotateAnimation(Real speed);

        void setTransformAnimation( const TextureTransformType ttype,
            const WaveformType waveType, Real base = 0, Real frequency = 1, Real phase = 0, Real amplitude = 1 );



//        void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0);

        void removeAllEffects(void);

        void removeEffect( const TextureEffectType type );

        bool isBlank(void) const;

        void setBlank(void);

	bool isTextureLoadFailing() const { return mTextureLoadFailed; }

	void retryTextureLoad() { mTextureLoadFailed = false; }

//        const EffectMap& getEffects(void) const;

        Real getAnimationDuration(void) const;

        void setTextureFiltering(TextureFilterOptions filterType);

        void setTextureFiltering(FilterType ftype, FilterOptions opts);

        void setTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);

        FilterOptions getTextureFiltering(FilterType ftpye) const;

        void setTextureAnisotropy(unsigned int maxAniso);

        unsigned int getTextureAnisotropy() const;

	void setTextureMipmapBias(float bias) { mMipmapBias = bias; }

	float getTextureMipmapBias(void) const { return mMipmapBias; }

	void setCompositorReference(const String& compositorName, const String& textureName, size_t mrtIndex = 0);

	const String& getReferencedCompositorName() const { return mCompositorRefName; }

	const String& getReferencedTextureName() const { return mCompositorRefTexName; }

	size_t getReferencedMRTIndex() const { return mCompositorRefMrtIndex; }
	
        Pass* getParent(void) const { return mParent; }

        bool hasViewRelativeTextureCoordinateGeneration(void) const;

        bool isLoaded(void) const;

        void _notifyNeedsRecompile(void);

        void setName(const String& name);

        const String& getName(void) const { return mName; }

        void setTextureNameAlias(const String& name);

        const String& getTextureNameAlias(void) const { return mTextureNameAlias;}

//        bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true);

		void _notifyParent(Pass* parent);

//		const TexturePtr& _getTexturePtr(void) const;

//		const TexturePtr& _getTexturePtr(size_t frame) const;
	
//		void _setTexturePtr(const TexturePtr& texptr);

//		void _setTexturePtr(const TexturePtr& texptr, size_t frame);

//		Controller<Real>* _getAnimController() const { return mAnimController; }
    };

}
